<!--********************************************************************
* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!--********************************************************************
* 该示例需要引入
* Echarts (https://github.com/apache/echarts)
*********************************************************************-->
<html>
<head>
    <meta charset='utf-8'/>
    <title data-i18n="resources.title_echartsLinesMillions_bjRoads"></title>
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no'/>
    <script type="text/javascript" include="jquery" src="../js/include-web.js"></script>
    <script type="text/javascript" include="echarts" src="../../dist/leaflet/include-leaflet.js"></script>
    <style>
        body {
            margin: 0;
            padding: 0;
        }

        #map {
            position: absolute;
            top: 0;
            bottom: 0;
            width: 100%;
        }
    </style>
</head>
<body>
<div id='map'></div>
<script type="text/javascript">
    var host = window.isLocal ? window.server : "https://iserver.supermap.io";
    var tileURL = host + "/iserver/services/map-china/rest/maps/ChinaDark";

    map = L.map('map', {
        center: [39.98, 116.36],
        maxZoom: 18,
        zoom: 10
    });
    new L.supermap.TiledMapLayer(tileURL).addTo(map);

    option = {
        progressive: 20000,
        title: {
            top: '10px',
            text: resources.text_echartsLinesMillions_bjRoads,
            subtext: resources.text_echartsLinesMillions_bjRoads_subtext,
            left: 'center',
            textStyle: {
                color: '#fff'
            },
            subtextStyle: {
                color: '#fff'
            }
        },
        series: [{
            type: 'lines',
            blendMode: 'lighter',
            coordinateSystem: 'leaflet',
            dimensions: ['value'],
            data: new Float64Array(),
            polyline: true,
            large: true,
            lineStyle: {
                color: 'orange',
                width: 1,
                opacity: 0.3
            }
        }]
    };

    var echartsLayer = new L.supermap.EchartsLayer(option).addTo(map);

    var CHUNK_COUNT = 19;

    function fetchData(idx) {
        if (idx > CHUNK_COUNT) {
            return;
        }
        var dataURL = "https://iclient.supermap.io/web/data/bigdata_beijingroads/data_" + idx + ".bin";
        var xhr = new XMLHttpRequest();
        xhr.open('GET', dataURL, true);
        xhr.responseType = 'arraybuffer';

        xhr.onload = function (e) {
            var rawData = new Float32Array(this.response);
            echartsLayer._ec.appendData({
                seriesIndex: 0,
                data: rawData
            });

            fetchData(idx + 1);
        };

        xhr.send();
    }

    fetchData(0);

</script>
</body>
</html>